import { defHttp } from '/@/utils/http/axios';
import { QueryMemberAccountBo } from '@/api/base-data/member-account/model/queryMemberAccountBo';
import { ChangeMemberAccountBo } from '@/api/base-data/member-account/model/changeMemberAccountBo';

const baseUrl = '/basedata/member-account';
const region = 'cloud-api';

/**
 * 根据会员ID查询会员积分账户
 * @param memberId 会员ID
 * @returns 会员积分账户
 */
export function getByMemberId(memberId: string): Promise<QueryMemberAccountBo> {
  return defHttp.get<QueryMemberAccountBo>(
    {
      url: baseUrl,
      params: {
        memberId: memberId,
      },
    },
    {
      region,
    },
  );
}

/**
 * 会员积分账户 变更积分
 * @param changeMemberAccountBo 变更积分Bo
 * @returns 变更积分结果
 */
export function changeScore(changeMemberAccountBo: ChangeMemberAccountBo): Promise<string> {
  return defHttp.post<string>(
    {
      url: baseUrl + '/change',
      data: changeMemberAccountBo,
    },
    {
      region,
    },
  );
}
